Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Get n-grams in JavaScript.
npm:
$ npm install n-gram
$ component install wooorm/n-gram
$ bower install n-gram
Duo:
var nGram = require('wooorm/n-gram');
UMD (globals/AMD/CommonJS) (uncompressed and compressed):
<script src="path/to/n-gram.js"></script>
<script>
nGram.bigram('n-gram'); // ['n-', '-g', 'gr', 'ra', 'am']
</script>
var nGram = require('n-gram');
nGram.bigram('n-gram'); // ['n-', '-g', 'gr', 'ra', 'am']
nGram(2)('n-gram'); // ['n-', '-g', 'gr', 'ra', 'am']
nGram.trigram('n-gram'); // ['n-g', '-gr', 'gra', 'ram']
nGram(6)('n-gram'); // ['n-gram']
nGram(7)('n-gram'); // []
Factory returning a function that converts a given string to n-grams.
Want padding? Use something like the following: nGram(2)(' ' + value + ' ');
Shortcut for nGram(2)
Shortcut for nGram(3)
On a MacBook Air, it runs about 583,367 op/s on a sentence.
nGram -- this module
583,367 op/s » bigrams on a sentence
4,250 op/s » bigrams on an article
566,931 op/s » trigrams on a sentence
4,204 op/s » trigrams on an article
542,756 op/s » ten-grams on a sentence
3,597 op/s » ten-grams on an article
madbence/ngram
538,421 op/s » bigrams on a sentence
9,842 op/s » bigrams on an article
525,198 op/s » trigrams on a sentence
9,253 op/s » trigrams on an article
539,926 op/s » ten-grams on a sentence
6,403 op/s » ten-grams on an article
FAQs
Get n-grams from text
The npm package n-gram receives a total of 0 weekly downloads. As such, n-gram popularity was classified as not popular.
We found that n-gram demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.